#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector < vector <int> > array(n, vector <int> (m) );
    for(int i = 0; i<n;i++){
        for(int j = 0; j<m;j++)
            cin>>array[i][j];
    }
    reverse(array.begin(), array.end());
    for (int i = 0; i < n; ++i) {
        int start = 0;
        int end = m - 1;
        while (start < end) {
            swap(array[i][start], array[i][end]);
            start++;
            end--;
        }
    }
    for (auto i : array) {
        for (auto j : i) {
            cout << j << " ";
        }
        cout << endl;
    }

}